abstract class Animal{
    private String name;  //名字
    private int age;   //年龄

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}

interface IAbility{
    void showInfo();  //输出动物信息
    void cry();    //动物发出叫声
}

class Dog extends Animal implements IAbility{

    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void showInfo() {
        System.out.println("我是一只狗，我的名字是" + this.getName() + ",今年" + this.getAge() + "岁");
    }

    @Override
    public void cry() {
        System.out.println("旺旺");
    }
}
class Cat extends Animal implements IAbility{

    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void showInfo() {
        System.out.println("我是一只猫，我的名字是" + this.getName() + ",今年" + this.getAge() + "岁");
    }

    @Override
    public void cry() {
        System.out.println("喵喵");
    }
}
class Simulator{
    public void playSound(IAbility animal){
        animal.showInfo();
        animal.cry();
        if (animal instanceof Dog) {
            System.out.println(((Dog) animal).getName());
        } else if (animal instanceof Cat) {
            System.out.println(((Cat) animal).getName());
        }
    }
}